package com.lg.partition12;

import java.io.*;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;

/**
 * @author `RKC`
 * @date 2022/3/23 15:34
 */
public class P1144最短路计数 {

    private static final int N = 1000010, M = 4000010, MOD = 100003;
    private static int[] h = new int[N], e = new int[M], ne = new int[M];
    private static int[] dist = new int[N], f = new int[N];
    private static boolean[] st = new boolean[N];
    private static Queue<Integer> q = new ArrayDeque<>(N);
    private static int n, m, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        Arrays.fill(h, -1);
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            add(a, b);
            add(b, a);
        }
        bfs(1);
        for (int i = 1; i <= n; i++) writer.write(f[i] + "\n");
        writer.flush();
    }

    private static void bfs(int start) {
        Arrays.fill(dist, 0x3f3f3f3f);
        dist[start] = 0;
        f[start] = 1;
        q.add(start);
        while (!q.isEmpty()) {
            int u = q.poll();
            if (st[u]) continue;
            st[u] = true;
            for (int i = h[u]; i != -1; i = ne[i]) {
                int v = e[i];
                if (dist[v] > dist[u] + 1) {
                    dist[v] = dist[u] + 1;
                    f[v] = f[u];
                    q.add(v);
                } else if (dist[v] == dist[u] + 1) {
                    f[v] = (f[v] + f[u]) % MOD;
                }
            }
        }
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
